#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main(void)
{
    int num, n;
    int index=0;
    scanf("%d", &n);
    int arr[52] = { 0 };
    for (int i = 0; i < n; i++)
        scanf("%d", &arr[i]);
    scanf("%d", &num);
    n++;
    for (int i = 0; i < n; i++)
    {
        if (arr[i] > num)
        {
            index = i;
            break;
        }
    }
    for (int i = n; i > index; i--)
        arr[i] = arr[i - 1];
    arr[index] = num;
    for (int i = 0; i < n; i++)
        printf("%d ", arr[i]);
    return 0;
}
